package com.aiyige.base.db.table;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

/**
 * Created by zhuyakun on 2017/11/29.
 */
@DatabaseTable(tableName = "DownloadFile")
public class DownloadFile {
    public static final String ID_FIELD = "id";
    public static final String CONTROL_OPTION_FIELD = "controlOption";
    public static final String PROGRESS_STATUS_FIELD = "progressStatus";
    public static final String DOWNLOAD_TIMESTAMP_FIELD = "downloadTimestamp";
    public static final String RETRY_COUNT_FIELD = "retryCount";
    public static final String PARENT_ID_FIELD = "parentId";
    public static final String USER_ID_FIELD = "userId";
    public static final String FILE_TYPE_FIELD = "fileType";
    public static final String DOWNLOADED_SIZE_FIELD = "downloadedSize";
    public static final String FILE_REMOTE_URL = "fileRemoteUrl";
    public static final String FILE_LOCAL_URL = "fileLocalUrl";
    public static final String COVER_REMOTE_URL = "coverRemoteUrl";
    public static final String COVER_LOCAL_URL = "coverLocalUrl";
    public static final String TOTAL_SIZE = "totalSize";
    public static final String DOWNLOAD_ID="downloadId";
    @DatabaseField(generatedId = true, columnName = ID_FIELD)
    int id;
    @DatabaseField(columnName = PARENT_ID_FIELD)
    String parentId;
    @DatabaseField(columnName = USER_ID_FIELD)
    String userId;
    @DatabaseField(columnName = FILE_LOCAL_URL)
    String fileLocalUrl;
    @DatabaseField(columnName = FILE_REMOTE_URL)
    String fileRemoteUrl;
    @DatabaseField(columnName = COVER_LOCAL_URL)
    String coverLocalUrl;
    @DatabaseField(columnName = COVER_REMOTE_URL)
    String coverRemoteUrl;
    @DatabaseField(columnName = TOTAL_SIZE)
    long totalSize;
    @DatabaseField(columnName = DOWNLOADED_SIZE_FIELD)
    long downloadedSize;
    @DatabaseField(columnName = PROGRESS_STATUS_FIELD)
    int progressStatus;
    @DatabaseField(columnName = FILE_TYPE_FIELD)
    int fileType;
    @DatabaseField(columnName = CONTROL_OPTION_FIELD)
    int controlOption;
    @DatabaseField
    String title;
    @DatabaseField
    String description;
    @DatabaseField
    long duration;
    @DatabaseField(columnName = DOWNLOAD_TIMESTAMP_FIELD)
    long downloadTimestamp;
    @DatabaseField(columnName = RETRY_COUNT_FIELD)
    int retryCount;
    @DatabaseField(columnName = DOWNLOAD_ID)
    int downloadId;
    boolean edit;
    boolean selected;

    public DownloadFile() {
    }

    private DownloadFile(Builder builder) {
        setId(builder.id);
        setParentId(builder.parentId);
        setUserId(builder.userId);
        setFileLocalUrl(builder.fileLocalUrl);
        setFileRemoteUrl(builder.fileRemoteUrl);
        setCoverLocalUrl(builder.coverLocalUrl);
        setCoverRemoteUrl(builder.coverRemoteUrl);
        setTotalSize(builder.totalSize);
        setDownloadedSize(builder.downloadedSize);
        setProgressStatus(builder.progressStatus);
        setFileType(builder.fileType);
        setControlOption(builder.controlOption);
        setTitle(builder.title);
        setDescription(builder.description);
        setDuration(builder.duration);
        setDownloadTimestamp(builder.downloadTimestamp);
        setRetryCount(builder.retryCount);
        setDownloadId(builder.downloadId);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public boolean isEdit() {
        return edit;
    }

    public void setEdit(boolean edit) {
        this.edit = edit;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getFileLocalUrl() {
        return fileLocalUrl;
    }

    public void setFileLocalUrl(String fileLocalUrl) {
        this.fileLocalUrl = fileLocalUrl;
    }

    public String getFileRemoteUrl() {
        return fileRemoteUrl;
    }

    public void setFileRemoteUrl(String fileRemoteUrl) {
        this.fileRemoteUrl = fileRemoteUrl;
    }

    public String getCoverLocalUrl() {
        return coverLocalUrl;
    }

    public void setCoverLocalUrl(String coverLocalUrl) {
        this.coverLocalUrl = coverLocalUrl;
    }

    public String getCoverRemoteUrl() {
        return coverRemoteUrl;
    }

    public void setCoverRemoteUrl(String coverRemoteUrl) {
        this.coverRemoteUrl = coverRemoteUrl;
    }

    public long getTotalSize() {
        return totalSize;
    }

    public void setTotalSize(long totalSize) {
        this.totalSize = totalSize;
    }

    public long getDownloadedSize() {
        return downloadedSize;
    }

    public void setDownloadedSize(long downloadedSize) {
        this.downloadedSize = downloadedSize;
    }

    public int getProgressStatus() {
        return progressStatus;
    }

    public void setProgressStatus(int progressStatus) {
        this.progressStatus = progressStatus;
    }

    public int getFileType() {
        return fileType;
    }

    public void setFileType(int fileType) {
        this.fileType = fileType;
    }

    public int getControlOption() {
        return controlOption;
    }

    public void setControlOption(int controlOption) {
        this.controlOption = controlOption;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public long getDuration() {
        return duration;
    }

    public void setDuration(long duration) {
        this.duration = duration;
    }

    public long getDownloadTimestamp() {
        return downloadTimestamp;
    }

    public void setDownloadTimestamp(long downloadTimestamp) {
        this.downloadTimestamp = downloadTimestamp;
    }

    public int getRetryCount() {
        return retryCount;
    }

    public void setRetryCount(int retryCount) {
        this.retryCount = retryCount;
    }

    public int getDownloadId() {
        return downloadId;
    }

    public void setDownloadId(int downloadId) {
        this.downloadId = downloadId;
    }

    public static final class Builder {
        private int id;
        private String parentId;
        private String userId;
        private String fileLocalUrl;
        private String fileRemoteUrl;
        private String coverLocalUrl;
        private String coverRemoteUrl;
        private long totalSize;
        private long downloadedSize;
        private int progressStatus;
        private int fileType;
        private int controlOption;
        private String title;
        private String description;
        private long duration;
        private long downloadTimestamp;
        private int retryCount;
        private int downloadId;

        private Builder() {
            id=0;
            parentId="";
            userId="";
            fileLocalUrl="";
            fileRemoteUrl="";
            coverLocalUrl="";
            coverRemoteUrl="";
            totalSize=0;
            downloadedSize=0;
            progressStatus=0;
            fileType=0;
            controlOption=0;
            title="";
            description="";
            duration=0;
            downloadTimestamp=0;
            retryCount=0;
            downloadId=0;
        }

        public Builder id(int id) {
            this.id = id;
            return this;
        }

        public Builder parentId(String parentId) {
            this.parentId = parentId;
            return this;
        }

        public Builder userId(String userId) {
            this.userId = userId;
            return this;
        }

        public Builder fileLocalUrl(String fileLocalUrl) {
            this.fileLocalUrl = fileLocalUrl;
            return this;
        }

        public Builder fileRemoteUrl(String fileRemoteUrl) {
            this.fileRemoteUrl = fileRemoteUrl;
            return this;
        }

        public Builder coverLocalUrl(String coverLocalUrl) {
            this.coverLocalUrl = coverLocalUrl;
            return this;
        }

        public Builder coverRemoteUrl(String coverRemoteUrl) {
            this.coverRemoteUrl = coverRemoteUrl;
            return this;
        }

        public Builder totalSize(long totalSize) {
            this.totalSize = totalSize;
            return this;
        }

        public Builder downloadedSize(long downloadedSize) {
            this.downloadedSize = downloadedSize;
            return this;
        }

        public Builder progressStatus(int progressStatus) {
            this.progressStatus = progressStatus;
            return this;
        }

        public Builder fileType(int fileType) {
            this.fileType = fileType;
            return this;
        }

        public Builder controlOption(int controlOption) {
            this.controlOption = controlOption;
            return this;
        }

        public Builder title(String title) {
            this.title = title;
            return this;
        }

        public Builder description(String description) {
            this.description = description;
            return this;
        }

        public Builder duration(long duration) {
            this.duration = duration;
            return this;
        }

        public Builder downloadTimestamp(long downloadTimestamp) {
            this.downloadTimestamp = downloadTimestamp;
            return this;
        }

        public Builder retryCount(int retryCount) {
            this.retryCount = retryCount;
            return this;
        }

        public Builder downloadId(int downloadId) {
            this.downloadId = downloadId;
            return this;
        }

        public DownloadFile build() {
            return new DownloadFile(this);
        }
    }
}
